package com.ruibang.glass.quality.controller.finish;

import com.ruibang.glass.quality.domain.req.GrindRangeReq;
import com.ruibang.glass.quality.entity.GrindRange;
import com.ruibang.glass.quality.service.GrindRangeService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import com.teaming.cloud.framework2.common.pojo.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;


/**
 * <p>
 * 成品离线检测-研磨幅 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-20
 */
@RestController
@RequestMapping("/api/quality/grind/range")
@Api(value = "成品离线检测-研磨幅控制器", tags = {"成品离线检测-研磨幅接口"})
public class GrindRangeController {

    @Autowired
    private GrindRangeService grindRangeService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取成品离线检测-研磨幅", notes = "获取成品离线检测-研磨幅")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(grindRangeService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增成品离线检测-研磨幅", notes = "新增成品离线检测-磨幅")
    public ResultBody save(@RequestBody @Valid GrindRange grindRange) {
        grindRangeService.insert(grindRange);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除成品离线检测-研磨幅", notes = "通过ID删除成品离线检测-研磨幅")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        grindRangeService.delete(id);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改成品离线检测-研磨幅", notes = "修改成品离线检测-研磨幅")
    public ResultBody updateById(@RequestBody GrindRange grindRange) {
        grindRangeService.edit(grindRange);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询成品离线检测-研磨幅", notes = "分页列表查询成品离线检测-研磨幅")
    public ResultBody pageQuery(@RequestBody PageRequest<GrindRangeReq> pageRequest) {
        return ResultBody.success(grindRangeService.pageQuery(pageRequest));
    }

    @PostMapping("/importExcel")
    @ApiOperation(value = "excel导入-研磨幅", notes = "excel导入-研磨幅")
    public ResultBody importExcel(@RequestParam("file") MultipartFile file) {
        return ResultBody.success(grindRangeService.importExcel(file));
    }
}
